{% extends "blog/base.html" %}

{% load i18n %}
{% load account_tags %}
{% load blog_tags %}
{% load markup %}
{% load switchcase %}
{% load tagging_tags %}
{% load restructuredtext %}
{% load theme_tags %}

{% block head_title %}{% blocktrans %}Your Blog Posts{% endblocktrans %}{% endblock %}

{% block extra_head %}
    <link rel="alternate" type="application/atom+xml" title="Blog Post Feed for All Users" href="/feeds/posts/all/" />
    <link rel="alternate" type="application/atom+xml" title="Blog Post Feed for User {% user_display user %}" href="/feeds/posts/only/{{ user.username }}/" />
{% endblock %}

{% block body %}
  
    <h1>{% trans "Your Posts" %}</h1>
    
    {% if blogs %}
        <table cellpadding="5" cellspacing="0" border="0" class="blog-list" width="100%">
            <th>Title</th>
            <th>Published On</th>
            <th>Status</th>
            <th></th>
            {% for post in blogs %}
                <tr class="{% cycle odd,even %}">
                    <td><b><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></b><br />
                        {% with post.tease|truncatewords:"50" as body %}
                            {% if post.markup %}
                                {% switch post.markup %}
                                    {% case 'rst' %}{{ body|restructuredtext|safe }}{% endcase %}
                                    {% case 'mrk' %}{{ body|force_escape|markdown }}{% endcase %}
                                    {% case 'txl' %}{{ body|force_escape|textile }}{% endcase %}
                                {% endswitch %}
                            {% else %}
                                {{ body|force_escape|linebreaks|safe }}
                            {% endif %}
                        {% endwith %}
                    </td>
                    <td nowrap>{{ post.publish|date }}</td>
                    <td>
                        {% with post.status as status %}
                            {% switch status %}
                                {% case 2 %}Published{% endcase %}
                                {% case 1 %}Draft{% endcase %}
                            {% endswitch %}
                        {% endwith %}
                    </td>
                    <td width="50px" align="center">
                        <a href="{% url blog_edit post.id %}">
                            {% silk "pencil" %}
                        </a>
                    </td>
                    <td align="right">
                        <form action="{% url blog_destroy post.id %}" method="POST">
                            {% csrf_token %}
                            {# @@@ still can't replace this with a silk tag yet #}
                            <input type="image" src="{{ STATIC_URL }}pinax/img/silk/icons/delete.png" border="0" title="{% trans "Delete Post" %}" />
                            <input type="hidden" name="action" value="delete"/>
                       </form>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        {% trans "No blog posts yet." %}
    {% endif %}
    
{% endblock %}
